from dkimageapp import dkimageapp

dkimageapp.core.addition_icon_autograph(
    source_image_path="imgs/IMG_2229.JPG",
    output_path="source_output.png",
    icon_path="imgs/icon.jpg",
    autograph="@61Duke",
    autograph_method="right_down",
    icon_method="right_down_circle"
)

dominant = dkimageapp.core.colour_dominant(image_path="imgs/IMG_2229.JPG")
print(dominant)
# (0.51, (35, 18, 26))

palette = dkimageapp.core.colour_ratio(image_path="imgs/IMG_2229.JPG")
print(palette)
# [(0.51, (35, 18, 26)), (0.19, (121, 41, 59)), (0.09, (142, 129, 110)), (0.07, (209, 129, 118)), (0.05, (214, 35, 62)), (0.04, (131, 102, 77)), (0.02, (225, 42, 115)), (0.02, (207, 188, 148))]


similarity = dkimageapp.core.colour_similarity(base_rgb=(255, 0, 0), compare_rgb=(255, 5, 50))
print(similarity)
# 0.4480129357712845

gps = dkimageapp.core.location_gps(image_path="imgs/IMG_2229.JPG")
print(gps)
"""
{
    "GPS": {
        "GPSLatitudeRef": "N",
        "GPSLatitude": 18.292461111111113,
        "GPSLongitudeRef": "E",
        "GPSLongitude": 109.52616944444445,
        "GPSAltitudeRef": "0",
        "GPSAltitude": "41477/8571",
        "GPSAddress": "海南省三亚市吉阳区河东区街道迎宾路329号三亚千古情景区"
    },
    "date": "2019:12:20 14:29:37"
}
"""

dkimageapp.core.crop_gif2images(
    source_image_path="imgs/test.gif",
    output_folder="source_output"
)

dkimageapp.core.crop_part_image(
    source_image_path="imgs/IMG_2229.JPG",
    output_path="source_output.png",
    box=(300, 200, 700, 800)
)

dkimageapp.core.stitch_images2gif(
    source_images_path=[
        "imgs/20191017185607410.png",
        "imgs/20191017185634484.png",
        "imgs/icon.jpg",
        "imgs/IMG_2229.JPG",
        "imgs/IMG_2994.JPG"
    ],
    output_path="source_output.gif"
)
dkimageapp.core.stitch_images(
    source_images_path=[
        "imgs/20191017185607410.png",
        "imgs/20191017185634484.png",
        "imgs/icon.jpg",
        "imgs/IMG_2229.JPG",
        "imgs/IMG_2994.JPG"
    ],
    output_path="output.png",
    layout=(4, 2),
    each_image_shape=(0, 0)
)
nearest_images = dkimageapp.core.retrieval_images_by_autoencoder(
    fit_images_path=[
        "imgs/20191017185607410.png",
        "imgs/20191017185634484.png",
        "imgs/icon.jpg",
        "imgs/IMG_2229.JPG",
        "imgs/IMG_2994.JPG"
    ],
    target_images_path=["122.JPG", "017.JPG"],
    scale=28,
    epochs=15,
    batch_size=32,
    n_neigh=5,
    shuffle=True
)
print(nearest_images)
"""
>>> {
        ...    "122.JPG": [
        ...        (1.0, "data/124.JPG"),
        ...        (0.021841750088447576, "data/535.JPG"),
        ...        (0.013354248283854897, "data/605.JPG"),
        ...        (0.009994627751588991, "data/402.JPG"),
        ...        (0.0, "data/134.JPG")
        ...    ],
        ...    "017.JPG": [
        ...        (0.11133096949872578, "data/510.JPG"),
        ...        (0.03817764172216209, "data/471.JPG"),
        ...        (0.02644454978659949, "data/IMG_2044.JPG"),
        ...        (0.001042320143904596, "data/130.JPG"),
        ...        (0.0, "data/472.JPG")
        ...    ]
>>> }

"""
